<div class="task">
<?php include ('buttons.tpl'); ?>
</div>
<?php if ($error) { ?>
<div class="warning"><?php echo $error; ?></div>
<?php } ?>
<h2><?php echo $heading_title; ?></h2>
<div class="description"><?php echo $heading_description; ?></div>

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
  
  <div id="tabs">
	<ul>
	  <li><a href="#tabs-1"><?php echo $tab_general; ?></a></li>
	  <li><a href="#tabs-2"><?php echo $tab_data; ?></a></li>
	  <li><a href="#tabs-3"><?php echo $tab_image; ?></a></li>
	</ul>
	<div id="tabs-1">
	  <?php foreach ($categories as $category) { ?>
      <fieldset>
        <legend><a><?php echo $category['language']; ?></legend>
        <table>
          <tr>
            <td width="185"><span class="required">*</span> <?php echo $entry_name; ?></td>
            <td><input name="language[<?php echo $category['language_id']; ?>][name]" value="<?php echo $category['name']; ?>" >
            <?php if ($error_name) { ?>
            <span class="error"><?php echo $error_name; ?></span>
            <?php } ?></td>
          </tr>
          <tr>
            <td valign="top"><?php echo $entry_description; ?></td>
            <td><textarea name="description[<?php echo $category['language_id']; ?>]" id="description<?php echo $category['language_id']; ?>" class="editor"><?php echo $category['description']; ?></textarea>
            <?php if ($error_description) { ?>
            <span class="error"><?php echo $error_description; ?></span>
            <?php } ?></td>
          </tr>
        </table>
      </fieldset>
      <?php } ?>
	</div>
	<div id="tabs-2">
	  <table>
        <tr>
          <td><?php echo $entry_status; ?></td>
          <td><select name="status">
              <?php if ($status == '1') { ?>
              <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
              <option value="0"><?php echo $text_disabled; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_enabled; ?></option>
              <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
              <?php } ?>
            </select></td>
        </tr>
        <tr>
          <td width="185"><?php echo $entry_sort_order; ?></td>
          <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" ></td>
        </tr>
      </table>
	</div>
	<div id="tabs-3">
	  <table>
        <tr>
          <td width="185"><?php echo $entry_upload; ?></td>
          <td><input type="file" name="image" id="fileInput" />
            <?php if ($error_upload) { ?>
            <span class="error"><?php echo $error_upload; ?></span>
            <?php } ?>
            <div class="fileUploadQueue" id="fileInputQueue"></div>
          </td>
        </tr>
        <tr>
          <td></td>
          <td><?php echo $text_or; ?></td>
        </tr>
        <tr>
          <td></td>
		  <td><span class="image" id="image_preview"></span></td>
		</tr>
		<tr>
		  <td><?php echo $entry_image; ?></td>
		  <td><select name="image_id" id="image_id">
		  <?php foreach ($images as $image) {?>
		  <option value="<?php echo $image['image_id']; ?>" <?php if ($image['image_id'] == $image_id) { ?> selected<?php } ?>><?php echo $image['title']; ?></option>
		  <?php } ?>
		  </select>
		  <input type="button" name="image_preview_less" id="image_preview_less" value="&laquo;" />
		  <input type="button" name="image_preview_more" id="image_preview_more" value="&raquo;" />
		  </td>
        </tr>
        <tr>
          <td></td>
	      <td></td>
        </tr>
      </table>
	</div>
  </div>
  <script type="text/javascript"><!--
	$(function() {
		$("#tabs").tabs();
	});
  //--></script>
</form>

<script type="text/javascript"><!--
	$('#image_preview').load('index.php?controller=image&action=view&image_id='+$('#image_id').val());
	$("#image_preview_more").click(function(){
	var val = parseInt($('#image_id').val())+1;
	$('#image_id').val(val);
	$('#image_preview').load('index.php?controller=image&action=view&image_id='+$('#image_id').val());
	});
	$("#image_preview_less").click(function(){
	var val = parseInt($('#image_id').val())-1;
	$('#image_id').val(val);
	$('#image_preview').load('index.php?controller=image&action=view&image_id='+$('#image_id').val());
	});
	$("#image_id").click(function(){
	$('#image_preview').load('index.php?controller=image&action=view&image_id='+$(this).val());
	});
	//$("#image_id option").hover(function(){
	//$('#image_preview').load('index.php?controller=image&action=view&image_id='+$(this).val());
	//});
//--></script>

<?php $tpl->addJS('jquery/uploadify/jquery.uploadify.js'); ?>
<script type="text/javascript">
$(document).ready(function() {
$('#fileInput').fileUpload ({
'uploader'  : 'javascript/jquery/uploadify/uploader.swf',
'script'    : 'javascript/jquery/uploadify/upload.php',
'cancelImg' : 'javascript/jquery/uploadify/cancel.png',
'auto'      : true,
'multi'		: true,
'fileExt'	: '*.jpg;*.jpeg;*.gif;*.png;',
'buttonImg' : 'http://dev.ektron.com/images/uploadIcon.gif',
'folder'    : '../image',
onAllComplete : 'function'
});
});
</script>

<?php if (isset($editor)) { echo $editor; } ?>